package com.cens.mall.ssoserver.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {

    @PostMapping("/doLogin")
    public String doLogin(@RequestParam("username") String username,@RequestParam("password") String password,@RequestParam("url") String url){
        if(username != null && password != null){
            //登录成功
            return "redirect:"+url;
        }
        //登录失败
        return "login";
    }

    @GetMapping("/login.html")
    public String loginPage(@RequestParam("redirect_url") String url, Model model){
        model.addAttribute("url",url);
        return "login";
    }
}
